<template>
	<view class="content">
		<view class="center">
			<u-form :model="BuyerInfo" ref="BuyerInfo" label-width="130" :border-bottom="false">
				<u-form-item label="收货人">
					<u-input v-model="BuyerInfo.Shipping" :clearable="false" />
				</u-form-item>
				<u-form-item label="手机号">
					<u-input v-model="BuyerInfo.mobile" :clearable="false" />
				</u-form-item>
				<u-form-item label-width="0">
					<view class="flex" @click="handleMap">
						<span class="form-text wordNoSpace">{{BuyerInfo.selAdd}}</span>
						<u-icon name="arrow-right" size="32"></u-icon>
					</view>
				</u-form-item>
				<u-form-item label-width="0">
					<u-input v-model="BuyerInfo.House" :clearable="false" />
				</u-form-item>
				<u-form-item label="设置为默认地址" label-width="210">
					<u-switch v-model="BuyerInfo.isValue" slot="right" size="36"></u-switch>
				</u-form-item>
			</u-form>
		</view>
		<view class="bot-btn">
			<u-button :custom-style="btnPlus" hair-line="false" shape="circle">保存地址</u-button>
		</view>
	</view>
</template>

<script>
	const key = 'RAPBZ-JIWCP-HB6D4-V2RWS-LUHZE-OHF34'; //使用在腾讯位置服务申请的key
	const referer = 'myapp'; //调用插件的app的名称  
	const location = "";
	const chooseLocation = requirePlugin('chooseLocation');
	export default {
		data() {
			return {
				latitude: 0,
				longitude: 0,
				checked: true,
				BuyerInfo: {
					selAdd: "四川省成都市高新区天府大道中段530号新希望国",
					Shipping: "李欣然",
					mobile: "12345678901",
					House: "A座11-1103",
					isValue: true
				},
				selectSite: {
					address: "四川省成都市武侯区天府大道1736号",
					city: "成都市",
					district: "武侯区",
					latitude: 30.56637,
					longitude: 104.06353,
					name: "成都环球中心天堂洲际大饭店",
					province: "四川省"
				},
				btnPlus: {
					width: "690rpx",
					height: "80rpx",
					bordeRadius: "40rpx",
					background: " #F74F6B",
					fontSize: "30rpx",
					color: "#FFFFFF"
				}
			}
		},
		created() {
			// this.handleMap()
		},
		onLoad(){
			
		},
		onShow() {
			const location = chooseLocation.getLocation();
			if (location) {
				this.selectSite = location;
				this.BuyerInfo.selAdd = location.address + location.name;
			}
		},
		methods: {
			getNowAddress() {
				let _this = this;
				uni.getLocation({
					type: 'gcj02',
					success: function(res) {
						_this.location = JSON.stringify({
							latitude: res.latitude,
							longitude: res.longitude
						})
					}
				});
			},
			handleMap() {
				uni.navigateTo({
					url: 'plugin://chooseLocation/index?key=' + key + '&referer=' + referer + '&location=' + location
				});
			}
		}
	}
</script>

<style scoped>
	.content {
		padding: 20rpx 20rpx 0;
	}

	.flex {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.center {
		border-radius: 12rpx;
		background: #FFFFFF;
		padding: 0 20rpx;
	}

	.form-text {
		width: 620rpx;
	}

	.bot-btn {
		position: fixed;
		bottom: 0;
		left: 0;
		padding: 24rpx 30rpx;
	}
</style>
